#ifndef __BLOCK_TABLE_H__
#define __BLOCK_TABLE_H__

#include <iostream>
#include <fstream>
#include <list>
#include "./includes/file_pointer_pack.h"
#include "./includes/register_pack.h"
#include "block_table_register.h"

class BlockTable{
	private:
		std::fstream free_space_stream;
		unsigned int blockSize;
		
	public:
		BlockTable(const std::string& path,unsigned int blockSize);
		
		~BlockTable();
		
		std::pair<BlockTableRegister,bool> getAvailBlock(const Register& reg);
				
		void writeBlockTableRegister(const BlockTableRegister& btr);
		
		BlockTableRegister readBlockTableRegister(const BlockTableRegister& btr);
		
		bool find(const BlockPointer& bp);
		
		void findLast(BlockPointer& bp);
		
		void createChain(std::list<unsigned long int>& chain,unsigned int nBlocks);
};

#endif /* __BLOCK_TABLE_H__ */
